package idv.takeshi.software.productline.bookstore.presentation.web.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.support.RequestContextUtils;

/**
 * An abstract simpleTagSupport class for collecting common used operations.
 * @author takeshi
 *
 */
public class AbstractSimpleTagSupport extends SimpleTagSupport {

	private String localeString;

	public AbstractSimpleTagSupport() {
		super();
	}

	/**
	 * @return the localeString
	 */
	protected String getLocaleString() {
		if(StringUtils.isBlank(this.localeString)){
			HttpServletRequest request = (HttpServletRequest) this.getJspContext().
				getAttribute(PageContext.REQUEST);
		
			this.localeString = RequestContextUtils.getLocale(request).toString();
		}
		return localeString;
	}

}